package git.soulbgm.controller;

import git.soulbgm.common.annotation.ParamCheck;
import git.soulbgm.common.enumerate.ParamCheckLevel;
import git.soulbgm.pojo.Check1;
import git.soulbgm.pojo.Check2;
import org.springframework.web.bind.annotation.*;

/**
 * @author SoulBGM
 * @version 1.0
 * @date 2019/9/23 15:33
 */
@RestController
public class CheckController {

    @RequestMapping(path = "add", method = RequestMethod.POST)
    public String add(@RequestBody @ParamCheck Check1 c1) {
        return c1.toString();
    }

    @RequestMapping(path = "del", method = RequestMethod.DELETE)
    public String del(@RequestBody @ParamCheck("n2") Check1 c1) {
        return c1.toString();
    }

    @RequestMapping(path = "update", method = RequestMethod.PUT)
    public String update(@RequestBody @ParamCheck(value = {"n1","n2"}, level = {ParamCheckLevel.NOT_EMPTY}) Check1 c1) {
//    public String update(@RequestBody @ParamCheck(value = {"n1","n2", "n3"}, level = {ParamCheckLevel.NOT_EMPTY}) Check1 c1) { , @RequestBody @ParamCheck("n3") Check1 c2
        return c1.toString();
    }

    @RequestMapping(path = "select", method = RequestMethod.GET)
    public String select(@ParamCheck(value = {"n2", "n3"}, level = ParamCheckLevel.NOT_NULL) Check1 c1, @ParamCheck({"n1","c2"}) Check2 c2) {
        return c1.toString() + " ; " + c2.toString();
    }

}
